For this project the location information is one of the defining aspects of the project and future developments. The data is entered into the table as the raw variable called “Exposure.Location”. This is the baseline gps information we are able to obtain from the data. There are a several packages that allow for these functions to work.
library()
Started on day …
[PRIVATE?? unverified as of sept 01]
This database can be extended however the current vertified database include exposure locations from xx date to xx data, Suburb.
Locations are reported on the ACT Health site including
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(tidyverse)
tab3 <- read_csv("https://raw.githubusercontent.com/green-striped-gecko/covid_canberra/main/data/last.csv")
## Rows: 238 Columns: 12
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (9): Status, Exposure.Location, Street, Suburb, Date, Arrival.Time, Depa...
## dbl (2): lat, lon
## lgl (1): moved
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
str(tab3)
## spec_tbl_df [238 x 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Status : chr [1:238] "New" "New" "New" "New" ...
## $ Exposure.Location: chr [1:238] "7-Eleven Mawson" "St George Bank Fyshwick (ATM)" "Friendly Grocer Narrabundah" "Narrabundah Pharmacy and Post Office" ...
## $ Street : chr [1:238] "1 Mawson Place" "58 Wollongong Street" "6 Iluka Street" "18 Iluka Street" ...
## $ Suburb : chr [1:238] "Mawson" "Fyshwick" "Narrabundah" "Narrabundah" ...
## $ Date : chr [1:238] "01/09/2021 - Wednesday" "01/09/2021 - Wednesday" "01/09/2021 - Wednesday" "01/09/2021 - Wednesday" ...
## $ Arrival.Time : chr [1:238] "7:20pm" "3:35pm" "9:35am" "1:30pm" ...
## $ Departure.Time : chr [1:238] "8:00pm" "4:35pm" "10:25am" "3:00pm" ...
## $ Contact : chr [1:238] "Monitor" "Monitor" "Monitor" "Monitor" ...
## $ lat : num [1:238] -35.4 -35.3 -35.3 -35.3 -35.2 ...
## $ lon : num [1:238] 149 149 149 149 149 ...
## $ doubles : chr [1:238] NA NA "<strong/>!Location has more than<br> one entry. Zoom in and search table!</strong/>" NA ...
## $ moved : logi [1:238] FALSE FALSE TRUE FALSE FALSE FALSE ...
## - attr(*, "spec")=
## .. cols(
## .. Status = col_character(),
## .. Exposure.Location = col_character(),
## .. Street = col_character(),
## .. Suburb = col_character(),
## .. Date = col_character(),
## .. Arrival.Time = col_character(),
## .. Departure.Time = col_character(),
## .. Contact = col_character(),
## .. lat = col_double(),
## .. lon = col_double(),
## .. doubles = col_character(),
## .. moved = col_logical()
## .. )
## - attr(*, "problems")=<externalptr>
# names(tab3)
datyl <-factor(tab3$Contact)
# levels(datyl)
datyl1 <- tab3 %>%
filter(Status >= "New")
names(tab3)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
# colsN <- cols[datyl1]
tab4 <- tab3 %>%
mutate(colsN = factor(Contact, levels = c("Close", "Casual", "Monitor","Investigation location")),
Contact = factor(Contact, levels = c("Close", "Casual","Monitor", "Investigation location")))
levels(tab4$colsN) <- c("purple", "red","orange", "grey50")
levels(tab4$colsN) <- c( "yellow", "red","cyan", "blue")
table(tab4$colsN)
##
## yellow red cyan blue
## 17 92 129 0
names(tab4)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
## [13] "colsN"
tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Exposure.Location))
##loc summaries
tab5 <- tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Suburb))
a <- as.data.frame(table(tab5$locName))
colnames(a) <- c("locName", "contactcount")
# head(a)
# str(a)
# filter(a, contactcount >=1)
plotsumms <- right_join(tab5, a)
## Joining, by = "locName"
print(a)
## locName contactcount
## 1 Ainslie 2
## 2 Amaroo 8
## 3 Barton 1
## 4 Belconnen 9
## 5 Braddon 8
## 6 Braddon & Turner 1
## 7 Calwell 2
## 8 Campbell 7
## 9 Canberra City 12
## 10 Casey 8
## 11 Charnwood 3
## 12 Chifley 1
## 13 Chisholm 7
## 14 Conder 11
## 15 Crace 1
## 16 Denman Prospect 1
## 17 Dickson 5
## 18 Evatt 1
## 19 Florey 1
## 20 Franklin 2
## 21 Fyshwick 11
## 22 Greenway 15
## 23 Griffith 2
## 24 Gungahlin 16
## 25 Holt 8
## 26 Lyneham 1
## 27 Macquarie 2
## 28 Majura Park 3
## 29 Mawson 6
## 30 Mitchell 2
## 31 Narrabundah 4
## 32 Ngunnawal 3
## 33 Nicholls 2
## 34 Palmerston 1
## 35 Phillip 21
## 36 Pialligo 1
## 37 Public Transport 14
## 38 Turner 2
## 39 Wanniassa 12
## 40 Watson 4
## 41 Weston 15
## 42 Woden 2
str(a)
## 'data.frame': 42 obs. of 2 variables:
## $ locName : Factor w/ 42 levels "Ainslie","Amaroo",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ contactcount: int 2 8 1 9 8 1 2 7 12 8 ...
# Aggregate method
# labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
nrow(tab4)
## [1] 238
#> [1] 100
nrow(distinct(plotsumms, Suburb))
## [1] 42
b <- distinct(plotsumms, Suburb, .keep_all = TRUE)
# subsTable <- semi_join(tab4, b)
#> [1] 69
# nrow(distinct(df, x, y))
# #> [1] 69
levels(plotsumms$locName)
## [1] "Ainslie" "Amaroo" "Barton" "Belconnen"
## [5] "Braddon" "Braddon & Turner" "Calwell" "Campbell"
## [9] "Canberra City" "Casey" "Charnwood" "Chifley"
## [13] "Chisholm" "Conder" "Crace" "Denman Prospect"
## [17] "Dickson" "Evatt" "Florey" "Franklin"
## [21] "Fyshwick" "Greenway" "Griffith" "Gungahlin"
## [25] "Holt" "Lyneham" "Macquarie" "Majura Park"
## [29] "Mawson" "Mitchell" "Narrabundah" "Ngunnawal"
## [33] "Nicholls" "Palmerston" "Phillip" "Pialligo"
## [37] "Public Transport" "Turner" "Wanniassa" "Watson"
## [41] "Weston" "Woden"
# distinct(df, x)
plotsumms <- b
plotsumms$Suburb[35] <- "O'Connor"
plotsumms$locName[35] <- "O'Connor"
## Warning in `[<-.factor`(`*tmp*`, 35, value = structure(c(29L, 21L, 31L, :
## invalid factor level, NA generated
# plotsumms$Suburb <- droplevels(plotsumms$Suburb)
# plotsumms$locName <- droplevels(plotsumms$locName)
clean <- plotsumms$Exposure.Location[4] <- "Assembly The People Pub"
# pre-processing
# ensure that all characters in the `Name` column
# are valid UTF-8 encoded
# Thank you to SO for this gem
# https://stackoverflow.com/questions/17291287/how-to-identify-delete-non-utf-8-characters-in-r
Encoding(x = plotsumms$Exposure.Location) <- "UTF-8"
# replace all non UTF-8 character strings with an empty space
plotsumms$Exposure.Location <-
iconv( x = plotsumms$Exposure.Location
, from = "UTF-8"
, to = "UTF-8"
, sub = "" )
labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
leaflet(plotsumms) %>% addTiles() %>%
addCircleMarkers(lat=plotsumms$lat,
lng=plotsumms$lon,
weight = 0.2,
radius = log(plotsumms$contactcount)*5,
color = plotsumms$colsN,
stroke = TRUE,
fill = rep("black", length(plotsumms$colsN)),
popup = paste0(" COUNT:", plotsumms$contactcount),
fillOpacity = 0.8
) %>%
addCircles(lat=tab4$lat,lng=tab4$lon,
popup = paste0(plotsumms$Exposure.Location," ", plotsumms$Date))
# %>%
# group_by(locName) %>%
# summarise(countPlace = count(Place))
# # %>%
# group_by(Suburb) %>%
# summarise(FirstCase = min(conDate),
# LastCase = max(conDate),
# caseCount = sum(unique(Place)))
# write.csv(x = plotsumms, "data/outSubs.csv")
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
This needs to account for projection, crs, points, polygons, SA levels etc…
Locations are reported on the ACT Health site including
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
library(lubridate)
library(tidyverse)
tab3 <- read_csv("https://raw.githubusercontent.com/green-striped-gecko/covid_canberra/main/data/last.csv")
## Rows: 238 Columns: 12
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (9): Status, Exposure.Location, Street, Suburb, Date, Arrival.Time, Depa...
## dbl (2): lat, lon
## lgl (1): moved
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
str(tab3)
## spec_tbl_df [238 x 12] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ Status : chr [1:238] "New" "New" "New" "New" ...
## $ Exposure.Location: chr [1:238] "7-Eleven Mawson" "St George Bank Fyshwick (ATM)" "Friendly Grocer Narrabundah" "Narrabundah Pharmacy and Post Office" ...
## $ Street : chr [1:238] "1 Mawson Place" "58 Wollongong Street" "6 Iluka Street" "18 Iluka Street" ...
## $ Suburb : chr [1:238] "Mawson" "Fyshwick" "Narrabundah" "Narrabundah" ...
## $ Date : chr [1:238] "01/09/2021 - Wednesday" "01/09/2021 - Wednesday" "01/09/2021 - Wednesday" "01/09/2021 - Wednesday" ...
## $ Arrival.Time : chr [1:238] "7:20pm" "3:35pm" "9:35am" "1:30pm" ...
## $ Departure.Time : chr [1:238] "8:00pm" "4:35pm" "10:25am" "3:00pm" ...
## $ Contact : chr [1:238] "Monitor" "Monitor" "Monitor" "Monitor" ...
## $ lat : num [1:238] -35.4 -35.3 -35.3 -35.3 -35.2 ...
## $ lon : num [1:238] 149 149 149 149 149 ...
## $ doubles : chr [1:238] NA NA "<strong/>!Location has more than<br> one entry. Zoom in and search table!</strong/>" NA ...
## $ moved : logi [1:238] FALSE FALSE TRUE FALSE FALSE FALSE ...
## - attr(*, "spec")=
## .. cols(
## .. Status = col_character(),
## .. Exposure.Location = col_character(),
## .. Street = col_character(),
## .. Suburb = col_character(),
## .. Date = col_character(),
## .. Arrival.Time = col_character(),
## .. Departure.Time = col_character(),
## .. Contact = col_character(),
## .. lat = col_double(),
## .. lon = col_double(),
## .. doubles = col_character(),
## .. moved = col_logical()
## .. )
## - attr(*, "problems")=<externalptr>
# names(tab3)
datyl <-factor(tab3$Contact)
# levels(datyl)
datyl1 <- tab3 %>%
filter(Status >= "New")
names(tab3)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
# colsN <- cols[datyl1]
tab4 <- tab3 %>%
mutate(colsN = factor(Contact, levels = c("Close", "Casual", "Monitor","Investigation location")),
Contact = factor(Contact, levels = c("Close", "Casual","Monitor", "Investigation location")))
levels(tab4$colsN) <- c("purple", "red","orange", "grey50")
levels(tab4$colsN) <- c( "yellow", "red","cyan", "blue")
table(tab4$colsN)
##
## yellow red cyan blue
## 17 92 129 0
names(tab4)
## [1] "Status" "Exposure.Location" "Street"
## [4] "Suburb" "Date" "Arrival.Time"
## [7] "Departure.Time" "Contact" "lat"
## [10] "lon" "doubles" "moved"
## [13] "colsN"
tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Exposure.Location))
##loc summaries
tab5 <- tab4 %>%
mutate(conDate = as.Date(lubridate::dmy(Date)),
locName = as.factor(Suburb))
a <- as.data.frame(table(tab5$locName))
colnames(a) <- c("locName", "contactcount")
# head(a)
# str(a)
# filter(a, contactcount >=1)
plotsumms <- right_join(tab5, a)
## Joining, by = "locName"
print(a)
## locName contactcount
## 1 Ainslie 2
## 2 Amaroo 8
## 3 Barton 1
## 4 Belconnen 9
## 5 Braddon 8
## 6 Braddon & Turner 1
## 7 Calwell 2
## 8 Campbell 7
## 9 Canberra City 12
## 10 Casey 8
## 11 Charnwood 3
## 12 Chifley 1
## 13 Chisholm 7
## 14 Conder 11
## 15 Crace 1
## 16 Denman Prospect 1
## 17 Dickson 5
## 18 Evatt 1
## 19 Florey 1
## 20 Franklin 2
## 21 Fyshwick 11
## 22 Greenway 15
## 23 Griffith 2
## 24 Gungahlin 16
## 25 Holt 8
## 26 Lyneham 1
## 27 Macquarie 2
## 28 Majura Park 3
## 29 Mawson 6
## 30 Mitchell 2
## 31 Narrabundah 4
## 32 Ngunnawal 3
## 33 Nicholls 2
## 34 Palmerston 1
## 35 Phillip 21
## 36 Pialligo 1
## 37 Public Transport 14
## 38 Turner 2
## 39 Wanniassa 12
## 40 Watson 4
## 41 Weston 15
## 42 Woden 2
str(a)
## 'data.frame': 42 obs. of 2 variables:
## $ locName : Factor w/ 42 levels "Ainslie","Amaroo",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ contactcount: int 2 8 1 9 8 1 2 7 12 8 ...
# Aggregate method
# labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
nrow(tab4)
## [1] 238
#> [1] 100
nrow(distinct(plotsumms, Suburb))
## [1] 42
b <- distinct(plotsumms, Suburb, .keep_all = TRUE)
# subsTable <- semi_join(tab4, b)
#> [1] 69
# nrow(distinct(df, x, y))
# #> [1] 69
levels(plotsumms$locName)
## [1] "Ainslie" "Amaroo" "Barton" "Belconnen"
## [5] "Braddon" "Braddon & Turner" "Calwell" "Campbell"
## [9] "Canberra City" "Casey" "Charnwood" "Chifley"
## [13] "Chisholm" "Conder" "Crace" "Denman Prospect"
## [17] "Dickson" "Evatt" "Florey" "Franklin"
## [21] "Fyshwick" "Greenway" "Griffith" "Gungahlin"
## [25] "Holt" "Lyneham" "Macquarie" "Majura Park"
## [29] "Mawson" "Mitchell" "Narrabundah" "Ngunnawal"
## [33] "Nicholls" "Palmerston" "Phillip" "Pialligo"
## [37] "Public Transport" "Turner" "Wanniassa" "Watson"
## [41] "Weston" "Woden"
# distinct(df, x)
plotsumms <- b
plotsumms$Suburb[35] <- "O'Connor"
plotsumms$locName[35] <- "O'Connor"
## Warning in `[<-.factor`(`*tmp*`, 35, value = structure(c(29L, 21L, 31L, :
## invalid factor level, NA generated
# plotsumms$Suburb <- droplevels(plotsumms$Suburb)
# plotsumms$locName <- droplevels(plotsumms$locName)
clean <- plotsumms$Exposure.Location[4] <- "Assembly The People Pub"
# pre-processing
# ensure that all characters in the `Name` column
# are valid UTF-8 encoded
# Thank you to SO for this gem
# https://stackoverflow.com/questions/17291287/how-to-identify-delete-non-utf-8-characters-in-r
Encoding(x = plotsumms$Exposure.Location) <- "UTF-8"
# replace all non UTF-8 character strings with an empty space
plotsumms$Exposure.Location <-
iconv( x = plotsumms$Exposure.Location
, from = "UTF-8"
, to = "UTF-8"
, sub = "" )
labs <- paste(plotsumms$Exposure.Location, plotsumms$Date,plotsumms$Arrival.Time, plotsumms$Departure.Time, sep="<br/>")
leaflet(plotsumms) %>% addTiles() %>%
addCircleMarkers(lat=plotsumms$lat,
lng=plotsumms$lon,
weight = 0.2,
radius = log(plotsumms$contactcount)*5,
color = plotsumms$colsN,
stroke = TRUE,
fill = rep("black", length(plotsumms$colsN)),
popup = paste0(" COUNT:", plotsumms$contactcount),
fillOpacity = 0.8
) %>%
addCircles(lat=tab4$lat,lng=tab4$lon,
popup = paste0(plotsumms$Exposure.Location," ", plotsumms$Date))
# %>%
# group_by(locName) %>%
# summarise(countPlace = count(Place))
# # %>%
# group_by(Suburb) %>%
# summarise(FirstCase = min(conDate),
# LastCase = max(conDate),
# caseCount = sum(unique(Place)))
# write.csv(x = plotsumms, "data/outSubs.csv")
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
Overall we can group locations and other attributes into different spatial areas. For mapping many projects the exact location is not know or is not needed/wanted for a range of obvious reasons. This set of functions takes the location information from each of the datasets and creates a uniform location entry that aligns with the desired spatial scale.
Here I have created for groups: North Canberra, Central Canberra,…..
This package allows aspects of this data to be linked with census and other data resources associated with this level of geo-spatial identification.
Overall we can group locations and other attributes into different spatial areas. Here I have created for groups: North Canberra, Central Canberra,…..
Manual grouping into four general areas….
This package allows aspects of this data to be linked with census and other data resources associated with this level of geo-spatial identification.
All current locations in cases